<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>后台管理</title>
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/bootstrap/css/bootstrap.min.css">
<link href="__PUBLIC__/Admin/css/style.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Admin/js/artDialog/skins/blue.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Js/validform/style.css">
<link rel="stylesheet" type="text/css" href="__PUBLIC__/Js/ThinkBox/css/ThinkBox.css" media="all">
<script src="__PUBLIC__/Admin/js/jquery-1.8.3.min.js"></script>
<script src="__PUBLIC__/Admin/js/artDialog/artDialog.js"></script>
<script src="__PUBLIC__/Admin/js/artDialog/plugins/iframeTools.js"></script>
<script src="__PUBLIC__/Admin/js/My97DatePicker/WdatePicker.js"></script>
<script src="__PUBLIC__/Js/validform/Validform.js"></script>
<script src="__PUBLIC__/Js/ThinkBox/jquery.ThinkBox.min.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Js/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Js/ueditor/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="__PUBLIC__/Js/ueditor/lang/zh-cn/zh-cn.js"></script>
</head>
<script> 

 
//显示图片选择框
function showImgBox(curElement){
	art.dialog.open('{:U('Img/imagesBox')}', {width: 800, height: 500,lock:true,title:'选择图片', ok:function(){
			var d = this.iframe.contentWindow.document;
			var img_url = $(d).find('#Imgselected').attr('img_url');
			$(curElement).parent().find("input[type='hidden']").eq(0).val(img_url);
			$(curElement).val('__PUBLIC__'+img_url);
			$(curElement).focus();
			$(curElement).blur();
			curElement.src = '__PUBLIC__'+img_url;
	}});
}

			 



    function error(msg){
		var d = artDialog({
			title: '操作错误',
			content: msg,
			cancel: false,
			ok: function () {
				
				}
		});
		d.show();
	}
	function success(msg){
		var d = artDialog({
			title: '操作成功',
			content: msg,
			cancel: false,
			ok: function () {
				
				}
		});
		d.show();
	}
	function sall(){
		$('.sall').each(function(index, element) {
            if($(this).attr('checked')=='checked'){
				$(this).attr('checked',false);
			}else{
				$(this).attr('checked',true);
			}
        });
	}
	
	function rall(){
		$('.sall').attr('checked',false);
	}
	//移动内容 到分类
	function movenews(e){
		var ids=new Array();
		$('.sall').each(function(index, element) {
            if($(this).attr('checked')=='checked'){
				ids.push($(this).val());
			}
        });
		if(ids.length>0){
			if(confirm('您确定要移动选中记录吗？')){
			    window.location.href="{:U('move')}?id="+ids.toString()+"&category_id="+e.value;
			}else{
				return false;
			}
		}else{
			error('请选择要移动的记录');
		}
	}
	function delall(){
		var ids=new Array();
		$('.sall').each(function(index, element) {
            if($(this).attr('checked')=='checked'){
				ids.push($(this).val());
			}
        });
		if(ids.length>0){
			if(confirm('您确定要删除选中记录吗？')){
			    window.location.href="{:U('delete')}?id="+ids.toString();
			}else{
				return false;
			}
		}else{
			error('请选择要删除的记录');
		}
	}
	
	$(document).ready(function(e) {
		//表单验证
		$(".checkoutform:eq(0)").Validform({
			ajaxPost:true,
			tiptype:function(data,s){
				if(s.type == 1){
					$.ThinkBox.success(data,{'delayClose':0});
				}
			},
			callback:function(data){
				if(data.status == 0){
					$.ThinkBox.error(data.info,{'delayClose':200});
					
				}else{
					$.ThinkBox.success(data.info,{'delayClose':200});
					
					window.location.href = data.url;

				}
			}
	    });
 		//头部菜单
		$('.topmenu').each(function(index, element) {
            $(this).mouseenter(function(e) {
				$(this).addClass('cur');
                $(this).find('ul').removeClass('h');
            });
			$(this).mouseleave(function(e) {
				$(this).removeClass('cur');
                $(this).find('ul').addClass('h');
            });
        });
		
		
        $('.data_list').each(function(index, element) {
            $(this).mouseenter(function(e) {
                $(this).css({'background':'#D7F7F9'});
            });
			$(this).mouseleave(function(e) {
                $(this).css({'background':'#fff'});
            });
			//$(this).find("input[type='checkbox']").click();
			$(this).find("input[type='checkbox']").click(function(){
					if($(this).attr('checked')=='checked'){
					
					    $(this).attr('checked',false);
				    }else{
					    $(this).attr('checked',true);
				    }
				});
			$(this).find("input[type='checkbox']").parent().click(function(e) {
				
                if($(this).find("input[type='checkbox']").attr('checked')=='checked'){
					
					$(this).find("input[type='checkbox']").attr('checked',false);
				}else{
					$(this).find("input[type='checkbox']").attr('checked',true);
				}
            });
        });
		
		//异步更新int字段
		$('.status_btn').each(function(index, element) {
            $(this).click(function(e) {
				$.ajax({
					url:"<?php echo U('ajaxUpdate');?>",
					type:"post",
					data:"data="+$(this).attr('field'),
					dataType:"json",
					success: function(data){
						if(data.status==1){
							$('.status_btn').eq(index).removeClass("status1");
							$('.status_btn').eq(index).removeClass("status0");
							$('.status_btn').eq(index).addClass("status"+data.data);
						}
					}
				});
            });
        });
    });
	
	//更新排序
	//key主键/field更新字段名/el当前按钮对象/url服务端地址
	function update_sort(key,field,el,url){
		var data=new Array();
		$("input[name='"+key+"']").each(function(index, element) {
            data.push($(this).val()+'_'+$(this).parent().parent().find("input[name='"+field+"']").val());
        });
		$.post(url,{'sort':data.toString(),'field':field},function(data){
			if(data=='OK'){
				if(el==''){
					success('更新成功');
				}
			}else{
				error('更新失败');
			}
		});
	}
	
	//更新排序,点击移动更新
	function update_sortClick(key,type,el,field,sendurl){
		var data=new Array();
		if(type=='up'){
			$(el).parent().parent().after($(el).parent().parent().prev());
		}else{
			$(el).parent().parent().next().after($(el).parent().parent());
		}
		$("input[name='"+key+"']").each(function(index, element) {
			$(this).parent().parent().find("input[name='"+field+"']").val(index+1);
            data.push($(this).val()+'_'+$(this).parent().parent().find("input[name='"+field+"']").val());
        });
		
		//列新排序
		update_sort(key,field,el,sendurl);
	}
</script>
<body>
<form action="{:U($tablename.'/add')}" method="post" class="checkoutform form-horizontal">
<input type="hidden" name="id" value="{$cur_setting.id}" /> 
<input type="hidden" name="parent_id" value="{$parent_id}" />
<input type="hidden" name="modules_id" value="{$modules_id}" />







<div class="container"> 
     <volist name="list" id="svo">
    
    
    <div class="form-group">
      <label class="col-sm-2 control-label">{$svo.remark}</label>
      <div class="col-sm-10">
         <!--单行文本框-->
    <eq name="svo['type']" value="0">
        <input name="{$svo.fieldname}" dataType="{$svo.vtype}" type="text" value="{$cur_setting[$svo['fieldname']]}" size="60" />
    </eq>
  <!--下拉框-->
    <eq name="svo['type']" value="2">
        <html:select name="{$svo['fieldname']}" options="svo['_select']" selected="cur_setting[$svo['fieldname']]" />
    </eq>
    <!--编辑框-->
    <eq name="svo['type']" value="3">
        <html:editor id="{$svo['fieldname']}_" name="{$svo['fieldname']}" type="UEDIT" style="width:400px;">{$cur_setting[$svo['fieldname']]}</html:editor>
    </eq>
    <!--多行文本-->
    <eq name="svo['type']" value="1">
        <textarea name="{$svo.fieldname}" cols="60" rows="6">{$cur_setting[$svo['fieldname']]}</textarea>
    </eq>
    <!--上传图片-->
    <eq name="svo['type']" value="4">
        <script>
			function uploaded{$svo.fieldname}(path,name){
				$("#"+name).attr("src",'__PUBLIC__'+path);
				$("input[name='"+name+"']").val(path);
			}
			function del_img{$svo.fieldname}(name){
				if(confirm('您确定要删除图片吗?')){
					var file=$("input[name='"+name+"']").val();
					$.post("{:U('delImgBypath')}",{'path':file},function(data){
						$("input[name='"+name+"']").val('');
						$("#"+name).attr('src','');
					});
				}else{
					return false;
				}
			}
		</script>
        <input type="hidden" name="{$svo.fieldname}" value="{$cur_setting[$svo['fieldname']]}" />
        <iframe frameborder="0" width="400" height="40" scrolling="no" src="{:U('upload',array('name'=>$svo['fieldname']))}"></iframe>
        <img style="max-width:200px" onclick="showImgBox(this);" src="<notempty name="cur_setting[$svo['fieldname']]">{:getThumbPath($cur_setting[$svo['fieldname']])}<else/>__PUBLIC__/Admin/images/defaultimg.png</notempty>" id="{$svo.fieldname}" height="80" />
    </eq>
    <!--图片上传结束-->
    <!--布局编辑框-->
    <eq name="svo['type']" value="6">
        <div style="" onclick="openthis(this);"><html:editor id="{$svo['fieldname']}" name="{$svo['fieldname']}" type="CHENHUIEDITOR" width="100%" height="500">{$cur_setting[$svo['fieldname']]}</html:editor></div>
    </eq>
    <!-- 布局编辑器结束 -->
      </div>
   </div>

</volist>

</div>




<table class="table table-bordered" cellpadding="0" cellspacing="0" background="0">
    


<tr>
	<td colspan="2" align="center" valign="middle"><button class="mybutton" type="submit">提交</button></td>
    </tr>
</table>

</form>

</body>
</html>
